Method, computer program product and device for training a neural network

ABSTRACT

A method, device and computer program product for training neural networks being adapted to process image data and output a vector of values forming a feature vector for the processed image data. The training is performed using feature vectors from a reference neural network as ground truth. A system of devices for tracking an object using feature vectors outputted by neural networks running on the devices.

FIELD OF INVENTION

The present teachings relate to a method, device and computer programproduct for training neural networks being adapted to process image dataand output a vector of values forming a feature vector for the processedimage data. The present teachings further relate to a system of devicesfor tracking an object using feature vectors outputted by neuralnetworks running on the devices.

BACKGROUND

When training a neural network, many different details around thetraining and the neural network (e.g., the architecture of the neuralnetwork, etc.) affects how a multi-dimensional space is formed by thenetwork. The mapping of an input data on this multi-dimensional spacewill form a feature vector for that specific input data.

The goal for the neural network is to set up the multi-dimensional space(hyperspace) such that similar input data (i.e., input data belonging tothe same identity or the same class, depending on what similaritiesamong the input data the neural network is trained to identify) will bemapped close together in this space, while different input data (i.e.,input data belonging to different identities/classes) will be mappedaway from each other. However, how this multi-dimensional space isformed depends on any one or a combination of the following examples:which training input data is used, and in which order they are inputtedto the network; the type of neural network that is used, what costfunction (also known as loss function or error function) that isimplemented, the number of layers of nodes etc.; the hardwarearchitecture of the device running the neural network when trained,(e.g., how float numbers are rounded, multiplied etc.), in thathardware; compression of input data, or other optimizations forcalculation speed; randomized initialization of network weights; and soon.

Moreover, the training cost function (or optimization cost function) ofa neural network often comprises some sort of stochastic function,making the training of two neural networks inherently different.

This means that even if independent training of two different networksis done in exactly the same way, using the same training input data inthe same order, there is no guarantee that a feature vector produced byone neural network for a certain input data can be compared with afeature vector produced by another neural network for the same inputdata.

There is thus a need for improvements within this context.

SUMMARY

In view of the above, an object of the disclosure is to solve or atleast reduce one or several of the drawbacks discussed above. Generally,the above objective is achieved by the attached independent patentclaims.

According to a first aspect, a method for training a first neuralnetwork being adapted to process image data and output a vector ofvalues forming a feature vector for the processed image data isprovided. The method comprises: retrieving a reference feature vector,the reference feature vector being calculated by processing a firsttraining image by a reference neural network, the reference neuralnetwork being adapted to process image data and output a vector ofvalues forming a feature vector for the processed image data; andtraining the first neural network to optimize a cost function, the costfunction comprising at least a first distance measure between thereference feature vector and a feature vector outputted by the firstneural network when processing the first training image, wherein thecost function is adapted to minimize the first distance measure.

By the term “neural network” should, in the context of presentspecification, be understood interconnected groups of nodes, inspired bythe vast network of neurons in a brain. Neural network may also be named“artificial neural network” (ANN). The term “deep learning” is alsocommonly used. A specific type of neural network that may be used inthis context is a convolutional neural network (CNN) but any other typeof feedforward neural network (FNN) may be used. Also, other types suchas recurrent neural network (RNN) or deep belief network (DBN) may beused.

By the term “feature vector”, should, in the context of presentspecification, be understood a vector in a multi-dimensional space whichhas been designed by the neural network performing the analysis duringthe training of the neural network. The dimensions in the space are mostcommonly not graspable for humans, as they describe the visual featureswhich the neural network has experienced as the most useful during theidentification or classification training. In this context, for example,the feature vector (also known as appearance vector) thus describes thevisual appearance of an object in the image data which the neuralnetwork has processed. The multi-dimensional space has been designed tocluster input data of a similar kind, and to separate input data of adifferent kind. Depending on what purpose the neural network has beendesigned for, “similar kind” and “different kind” mean different things.The most common case for neural networks designed for monitoringpurposes is to perform identification of objects (e.g., persons) inimages processed by the neural network. In this context, input data ofsimilar kind means input data comprising persons of the same identity,while input data of different kind means input data comprising personsof different identity. The neural network is in this case designed toidentify persons, and cluster input data showing persons of the sameidentity, even if, for example, the images has been taken from differentangles etc. In other embodiments, the neural network has been trained tocluster input data of the same class (a distribution into groups, asclasses, orders, families, etc., according to some common relations orattributes), for example, dogs of the same breed or separate (e.g., carsfrom bicycles). In this context, input data of similar kind means inputdata comprising objects of the same class, while input data of differentkind means input data comprising objects of different class. In otherwords, the aim is to let the feature vector characterize the aspects ofthe visual appearance relevant for the analytics task that the networkwas trained for, (e.g., for person re-identification). The featurevector contains invariant aspects between individuals that makes itpossible to tell if two images depict the same person or not, but thedependence on appearance differences due to any one or a combination ofpose/angles, lighting differences, sharpness of images, etc., aresuppressed as much as possible in the feature vectors.

In the context of neural networks, such networks are trained using acost function, which the learning process attempts to optimize (oftenminimize but it the cost function could also be designed to bemaximized). Generally, the neural networks need to be trained to processthe data according to the needs of the users as described above. Theneural network should be trained to optimize performance with respect tothe cost function. During training of the neural network, the learningalgorithm depend upon the gradients of the cost function to find aminimum (or maxima) of the cost function. The minimum found may in somecases be a local minimum. So, in the context of the present embodiment,in case the distance measure between the reference feature vector and afeature vector outputted by the first neural network is large, the costwill be large and the weights of the first neural network is updated tomake the cost smaller (according to the gradient of the cost function).

As described above, when training a neural network, many differentdetails around the training and the design/architecture of the neuralnetwork affects how the multi-dimensional space is formed by thenetwork. The values of the output feature vector for each input imagedata are dependent on how the space is formed.

With the present embodiment, feature vectors from image data that wasprocessed by neural networks implemented on different devices can becompared. For example, the feature vectors can be compared even if thearchitecture of the hardware of the devices or the architecture of theneural networks differs. This is possible since the output from areference neural network has been used as a ground truth when trainingthe neural networks. By training the first neural network using featurevectors (i.e., reference feature vectors) outputted from the referenceneural network (can also be called common neural network, second neuralnetwork, etc.), the multi-dimensional space of the first neural networkwill converge towards the multi-dimensional space of the referenceneural network. The reference neural network will thus have anormalizing effect on any neural network trained as described herein.

A further advantage of the present embodiment is that the implementationof the first neural network, (e.g., choice of architecture, number ofnodes, type of neural network etc.), can be done without considering, orknowing about, the specifics of the reference neural network.Furthermore, a plurality of first networks can be trained, without anydetails of each other, or even without knowing of each other'sexistence, and still produce comparable output feature vectors since themulti-dimensional space of each neural network will be similar.

A further advantage of the present embodiment is that the referenceneural network can be trained to a desired accuracy, for example, usinga vast number of training images, or be implemented on a device adaptedfor producing very accurate results (the “best” architecture). Anotheradvantage may be that no time constrains or hardware constrains existsfor training the reference neural network, since this can be doneoffline on a dedicated device or well in advance of the training of thefirst neural network. The reference neural network can be kept aproprietary secret and does not need to be exposed, only the referencefeature vectors need to be accessible for the first neural network.

According to some embodiments, the reference neural network has beentrained using a triplet-based cost function, wherein the triplet-basedcost function aims to separate a pair of input images of a sameclassification or identification from a third input image of anotherclassification or identification, such that a difference between a firstdistance between the pair of input images of the same classification oridentification, and a second distance between one of the pair of inputimages of the same classification or identification and the third inputimage, is at least a distance margin, alpha, wherein the step oftraining the first neural network to optimize the cost functioncomprises reducing the first distance measure to at least alpha dividedby four.

By the term “triplet-based cost function”, should, in the context ofpresent specification, be understood a function for minimizing, orreducing, a distance between a first input image (also known as ananchor) comprising an object being of a first classification oridentification and a second input image (also known as a positive)comprising an object being of the same classification or identification.The triplet-based cost function should further accomplish that adistance between the first input image and a third image (also known asa negative) comprising an object being of another classification oridentification is at least alpha larger than the distance between theanchor-positive pair of input images. This means that the alpha value isused to create a difference in separation between anchor-positive andanchor-negative pairs such that, for a specific triplet of images, thedistance between the anchor-negative pair is at least alpha larger thanthe distance between the anchor-positive pair. It should be noted thatalpha is always a positive number. In case, the difference between thedistance between the anchor-positive pair and the distance between theanchor-negative pair of a triplet is smaller than alpha, the costfunction will change the weights of the neural network to increase thedifference towards alpha. It should also be noted that reaching thealpha distance margin may be an iterative process. The triplet basedcost function will change the weights such that the difference isincreased towards alpha, but the alpha distance margin may not bereached in one iteration. It is an iterative process to meet all alphaconditions for all images in the training database and alpha distancemargin is not achieved for a particular triplet, the gradients which iscalculated based on the cost function to make the weights to change suchthat the particular triplet will come a little closer to meeting alphamargin. However, if the difference already is larger than alpha, thecost function will not affect the weights of the neural network for thatspecific triplet. Accordingly, separation of image data being ofdifferent classifications or identifications in the neural networkhyperspace are achieved. Details of this alpha value are disclosed inpublished articles, for example in the article “FaceNet: A UnifiedEmbedding for Face Recognition and Clustering” by Schroff et al. (GoogleInc.).

Using the alpha value in the training of the first network, and reducingthe distance between the feature vector of the first neural network andthe reference feature vector retrieved from the reference neural networkto at least alpha/4 may provide a good value for when the first neuralnetwork is “good enough”, and where the training may be stopped, sincean error of alpha/4 still means that an object of a specificclassification will be classified in the correct class, albeit with anerror compared to the reference vector. This will be further explainedin conjunction with FIGS. 6-7 below. This embodiment may increase thespeed of the training. According to some embodiments, the step ofretrieving a reference feature vector comprises transmitting the firsttraining image to the reference neural network, processing the firsttraining image by the reference neural network, and retrieving theoutputted feature vector from the reference neural network. In this way,the reference neural network need not have “seen”, or have been trainedon, the first training image before. The first training image may be animage specific for the image processing task of the first neural network(e.g. processing images captured at a subway station, or in an entranceof an office building etc.). The first training image may then beprocessed by the reference neural network which then returns the featurevector for retrieval by the first neural network.

According to some embodiments, the step of retrieving a referencefeature vector comprises using data pertaining to the first trainingimage as a key in a database comprising feature vectors, and retrievingthe value corresponding to the key from the database. In thisembodiment, a specific set of images have already been processed by thereference neural network and the resulting feature vectors have beenstored in a database, using data (e.g., a fingerprint of the image suchas a hash value) pertaining to the corresponding image as key. Thetraining of the first neural network may thus comprise sending said datapertaining to the training image, or optionally the entire trainingimage, to the database which optionally extracts the data to be used askey in the database (e.g., hash value) from the data received from thefirst neural network, and retrieving the feature vector which haspreviously been produced by the reference neural network (i.e., beingthe ground truth for training the first neural network) from thedatabase. This embodiment may save time when training the first neuralnetwork, and also bandwidth since the entire training image according tosome embodiments needs not to be transmitted.

According to some embodiments, the first distance measure is theEuclidian distance between the reference feature vector and the featurevector outputted by the first neural network. This is a computationallyinexpensive distance measure. Alternatively, other distance measuressuch as any p-norm metric or measure may be used.

According to some embodiments, the first neural network and referenceneural network are different types of neural networks. For example,different types of software libraries (e.g., Open Source) or networkarchitectures may have been used. Example of such network architecturesinclude GoogLeNet, AlexNet etc. Example of software libraries areTensorFlow, Caffe etc. According to other embodiments, the first andreference neural network comprises different quantities of layers,different quantities of nodes in each layer, etc. The term “differenttypes of neural networks” further encompass different bit widths in theinternal number representation of the first neural network and referenceneural network, which otherwise may have the same network architecture.The term further encompasses a pruned (some small weights are set tozero to speed up calculation) but otherwise similar network, or anetwork using optimized functions for some of its operations (e.g.,having specific functions doing optimized convolutions by using sometricks that may produce smaller accuracy errors) etc.

According to some embodiments, the first neural network is implementedby a device having a first hardware architecture, and the referenceneural network is implemented by a device having a second hardwarearchitecture being different from the first hardware architecture. As anexample, the first neural network may be a very small integer neuralnetwork running on an embedded device while the reference neural networkis large floating point network running in the cloud, or on a dedicatedcomputing box.

According to some embodiments, the steps of any of the previousembodiments are iterated for a plurality of training images.

According to some embodiments, the method further comprises associatingthe first neural network with a version number, the version numberreflecting a version number of the reference neural network at the timewhen the first neural network was trained with reference feature vectorsfrom the reference neural network. Using version numbers as in thisembodiment may facilitate knowing when there is a need to upgrade orre-train the first neural network.

In a second aspect, a computer-readable storage medium with instructionsadapted to carry out the method of any embodiment of the first aspectwhen executed by a device having processing capability is provided.

In a third aspect, a device comprising a first neural network beingadapted to process image data and output a vector of values forming afeature vector for the processed image data is provided. The devicecomprising a processor configured to: retrieve a reference featurevector, the reference feature vector being calculated by processing afirst training image by a reference neural network, the reference neuralnetwork being adapted to process image data and output a vector ofvalues forming a feature vector for the processed image data; and trainthe first neural network to optimize a cost function, the cost functioncomprising at least a first distance measure between the referencefeature vector and the feature vector outputted by the first neuralnetwork when processing the first training image, wherein the costfunction is adapted to minimize the first distance measure.

In a fourth aspect, a system comprising a plurality of device isprovided. Each device comprises a first neural network trained accordingto the first aspect, wherein each device is further adapted to extractan object from an image, using the first neural network to process imagedata of the extracted object and transmit a feature vector outputtedfrom the first neural network, wherein the system further comprises anobject tracking unit adapted to receive feature vectors from thedevices, and track an object through the system of devices based on thereceived feature vectors.

As described above, using a common, reference neural network forproviding the reference feature vector for a training image, and usingthis for training other neural networks, the trained neural networks aresteered to produce a similar multi-dimensional space, such that theoutput feature vectors from each neural network for a certain image canbe compared in a meaningful way (since all feature vectors exist in thesame, or very similar, vector space). Consequently, the feature vectorsfrom different neural networks (implemented on different devices) can becompared and thus used for tracking an object.

According to some embodiments, the first neural network of each of theplurality of devices further is associated a version number, the versionnumber reflecting a version number of the reference neural network atthe time when the first neural network was trained, wherein the versionnumber of a device of the plurality of devices is transmitted togetherwith the feature vector outputted from the first neural network, andwherein the object tracking unit is adapted to track an object throughthe system of devices based on the received feature vectors and versionnumbers.

According to some embodiments, at least one of the plurality of devicesis a network camera, wherein the object is extracted from an imagecaptured by the network camera.

According to some embodiments, the object tracking unit is implementedin at least one of the plurality of devices, wherein the transmission ofa feature vector from a device is implemented using multicast orbroadcast transmission.

According to some embodiments, the object tracking unit is implementedin a further device separate from the plurality of devices and connectedto each of the plurality of devices.

The second, third and fourth aspect may generally have the same featuresand advantages as the first aspect.

BRIEF DESCRIPTION OF THE DRAWINGS

A more detailed understanding may be had from the following description,given by way of example in conjunction with the accompanying drawingswhere:

FIG. 1 shows a neural network processing an input image and outputting afeature vector describing the input image;

FIG. 2 shows feature vectors of two objects in a two-dimensional featurespace processed by two different neural networks;

FIG. 3 shows training of a neural network according to embodiments;

FIG. 4 shows a system of devices used for tracking an object captured byimages;

FIG. 5 shows a method for training a neural network according toembodiments;

FIG. 6 shows a distance margin which is the smallest distance betweenclusters of images with the same classification mapped in themulti-dimensional space of the reference neural network; and

FIG. 7 shows the use of alpha value of the reference neural network whentraining the first neural network.

DETAILED DESCRIPTION

FIG. 1 shows by way of example functionality of a neural network 104.Using a neural network may be a good way of solving computer visionproblems like object recognition where a rule based approach may notwork well. It may be difficult to define distinguishing features of an(complex) object compared to other objects of another type (i.e., class)using a rule based approach, especially when it is not known beforehandwhat type of objects that need to be recognized and distinguishable fromeach other. Here lies one of the strengths of a neural network. Whenidentifying or classifying objects with a neural network, the output maybe a feature vector. This is shown in FIG. 1 where an input image 102(or input image data 102) is processed by the neural network 104. Theoutput from the neural network is a feature vector 106. In the exampleof FIG. 1, the dimensionality of the feature vector 106 is four, butthis is only by way of example. The feature vector 106 describe thevisual appearance of the object in the input image 102. The featurevector 106 is a vector in a multi-dimensional space which has beendesigned by the neural network 104 performing the analysis. Thedimensions (four in number in this example, each represented by a value106 a-d in the feature vector 106) in the space are most commonly notgraspable for humans, as they describe the visual features which theneural network 104 has experienced as the most useful for identificationor classification of objects and separation between objects of differentidentities/classes during the training of the neural network 104.

However, as described above, different neural networks may come up withdifferent types of feature vectors (in different incomparable featurespaces) for the same objects.

FIG. 2 shows by way of example mappings of two objects (shown asfour-sided stars and diamonds in FIG. 2) made by two different neuralnetworks in a two-dimensional space. In this simplified example, the twoneural networks have outputted vectors of the same dimensionality. Thisis typically the case, but it is possible that vectors of differentdimensionally is outputted by two different neural networks. Often, inorder to achieve a good classification of complex objects using a neuralnetwork, 100-1000 dimensions are needed. In FIG. 2, two dimensions areused for simplicity. One neural network has classified the stars 202 tothe left (lower x-values) and the diamond 208 to the right (higherx-values) in the two-dimensional space of FIG. 2, while the other neuralnetwork has classified to stars 204 to the right (higher x-values) andthe diamonds 206 (lower x-values) to the left. If the feature vectorsfrom the two neural networks for the two different objects would be useddirectly for comparing objects, the diamond of the first neural networkwould be matched to the star of the second network and vice versa. Thismay become a problem in a monitoring system where different monitoringcameras, video encoders and video servers (each having separate neuralnetworks used for object classifications) are used to track objects (ofthe same identity or, in some less typical embodiments, class) over themonitoring system.

The present disclosure provides a solution of this problem. In summary,the problem is solved by training the neural network(s) against areference neural network. This will now be exemplified in conjunctionwith FIG. 3 and in FIG. 5. A first neural network 104 (i.e., the neuralnetwork to be trained) is adapted to process image data 310 and output avector of values 106 a-d forming a feature vector 106 for the processedimage data 310. In order to “force” a feature vector 106 outputted for aspecific input image data 310 to be comparable for neural networkshaving different architecture, or being trained using different trainingimages, or being run on hardware with different specifications, areference neural network (second neural network) 302 is used for thetraining. It is assumed that the reference neural network 302 is trainedto a desired accuracy. During the training of the first neural network104, no changes are performed to, for example, the weights of thereference neural network 302. For a training image 310, the first neuralnetwork 104 calculates a feature vector 106. Moreover, the first neuralnetwork 104 retrieves S508 a reference feature vector 306 which is usedas the ground truth (i.e., correct feature vector) for this specifictraining image 310. This may be done by requesting S502 the referencefeature vector for the training image 310 from, for example, a service312 providing such reference feature vectors. According to someembodiments, retrieving a reference feature vector 306 comprisestransmitting the first training image 310 to the reference neuralnetwork 302. The reference neural network 302 may then process S504 thefirst training image 310. The first neural network 104 can then retrieveS508 the outputted feature vector 306 (ground truth) from the referenceneural network 302. For example, the service 312 providing referencefeature vectors may transmit the reference feature vector 306 to therequesting neural network 104 when the reference feature vector 306 hasbeen outputted by the reference neural network 302. This embodiment mayfor example facilitate training of the first neural network 104 withtraining images which the reference neural network 302 has not processedbefore. In other embodiments, retrieving the reference feature vector306 comprises using data 310′ pertaining to the first training image 310and transmit this data 310′ to the service 312 providing referencefeature vectors. The data 310′ may be any type of unique identifier ofthe training image 310, for example the entire training image 310, ahash value of the training image 310 or a predetermined identifier forthe training image 310. The data 310′ can then be used as a key in adatabase 304 (optionally, the data 310′ is pre-processed at the service312 to be in the correct format for the database, wherein thepre-processed data still will be data pertaining to the first trainingimage 310) for finding the reference feature vector 306 for the trainingimage 310 in the database 304. The database 304 has previously beenprovided with reference feature vectors and identifiers for eachreference feature vector, where the reference feature vectors have beencalculated by the reference neural network 302. In this embodiment, apredefined set of images has been determined and processed by thereference neural network 302, before training of the first neuralnetwork (using images from the predefined set of images for training)can be performed.

When the reference feature vector 306 has been retrieved, the firstneural network 104 may be trained such that it will output featurevectors 106 comparable to the feature vectors outputted by the referenceneural network 302. This is done by reducing a cost function 308(schematically represented by the S-like symbol in FIG. 3), where thecost function 308 comprises at least a first distance measure betweenthe reference feature vector 306 and the feature vector 106 outputted bythe first neural network 104 when processing the first training image310. The cost function is thus adapted, for example, by changing weightsbetween neurons (nodes) in the neural network, to minimize the firstdistance measure such that the output feature vector 106 will be closer(more comparable) to the reference feature vector. The details of such acost function are left to the skilled person to implement, butgenerally, the cost function is optimized to reach a minimum or maximumin which the first distance measure is, at least locally, minimized.

Consequently, the first neural network is trained to optimize the costfunction, such that the cost function is adapted to minimize thedistance between the output feature vector 106 and the reference featurevector 306. There may be performance limitations in how close thefeature vectors from the first neural network and reference featurevectors might become, however, by using the above method for trainingneural networks, all neural networks trained against the same referenceneural network may generate comparable feature vectors within someconfidence level. According to some embodiments, data relating to thetraining of the reference neural network may be used for training thefirst neural network to a reasonable confidence level. Specifically, incase the reference neural network has been trained using so calledtriplet training, which comprises training using a pair of input imageswith a same identification or classification and a third input imagewith another identification/classification, the so called distancemargin for such training can be used when training the first neuralnetwork. In this type of training, the cost function of the neuralnetwork aims to separate the pair of input images of the sameidentification/classification from the third input image of said anotheridentification/classification with at least the distance margin, alsocalled alpha.

FIGS. 6-7 schematically describe the distance margin alpha α which inpart determines the smallest distance between clusters of images withthe same identification/classification mapped in the multi-dimensionalspace. As can be seen in FIG. 6, the distance between any of the threeclusters 602-606 are alpha α+r1/r2/r3. The values r1 corresponds tomax(distance between most separated feature vectors in cluster 604,distance between most separated feature vectors in cluster 606). In thesame way, values r2/r3 depends on the spreading of the clusters 602, 604and 602, 606 respectively. By the above described way of training thereference neural network using triplet training, the end result will, ina perfect scenario where all triplet combinations have been seen tofulfil the alpha requirement, become as described in FIG. 6 where ther1/r2/r3 distances represent the smallest distances such that allcombinations of triplets selected from the clusters of images give zeroerror from the loss function. It should be noted that such perfecttraining almost never occurs, (i.e., where all combinations of tripletsselected from the clusters of images give zero error from the lossfunction). For example, this is because it is not feasible to train onall triplet combinations since they are simply too many, and in anyevent, it cannot be guaranteed that the neural network ever will be ableto converge to a state that is able to perform that well. FIG. 6 ishowever for a well-trained network likely to be a good enoughapproximation for the current discussion of the alpha value with respectto the accuracy of the training of the first network.

The separation of clusters 602-606 will thus differ, but all will inpart be determined by the alpha value. In this embodiment, the step oftraining S510 the first neural network to optimize the cost functioncomprises reducing the first distance measure to at least alpha dividedby four. This is the smallest distance in which it is still reasonablelikely that the output feature for a specific input image data willresult in a correct classification/identification (i.e.,classified/identified as it would be using the reference neuralnetwork).

FIG. 7 shows, in a simplified way, the rationale behind the valuetraining the first neural network to minimize the first distance measureto at least alpha divided by four. For ease of description, in FIG. 7,each image data has been processed and mapped to a single dimensionspace, (i.e., the outputted feature vector comprises one value). Twofeature vectors for each cluster 602, 606 are shown, which represent thefeature vectors furthest away from each other but still having the sameidentity/class, (i.e. most separated feature vectors in each cluster602, 606). The distance between the feature vectors in the left cluster602 is thus d1, and the distance between the feature vectors in theright cluster 606 is thus d1. As described above, the distance betweenthe two closest feature vectors of different identities/classes in themulti-dimensional space is α+max(d1, d2). As shown in FIG. 7, thisseparation allows for some margin when training the first neuralnetwork, and still produces a correct identification/classification forthe involved processed image data. The margin in this case is alpha/4.In case all feature vectors are off by alpha/4 in the “wrong way” suchthat the distance between the samples (e.g., stars in FIG. 7,representing the feature vector for each sample) in the same cluster602, 604 is increased, and the distance between the “outer” samples inneighboring clusters is increased, the closest feature vectors ofdifferent identities/classes will still be further away from each otherthan the feature vectors within a same cluster 602, 604 which arefurthest away from each other.

As described above, using the method for training the first neuralnetwork 104 may result in comparable feature vectors outputted from thefirst 104 and the second 302 neural network even though they for exampleare different types of neural networks. For example, the referenceneural network may be implemented using a first network architecture,and the first neural network may be implemented using a differentnetwork architecture. Furthermore, using the method for training thefirst neural network 104 may result in comparable feature vectorsoutputted from the first 104 and the second 302 neural network eventhough the first neural network 104 is implemented by a device having afirst hardware architecture, and the reference neural network 302 isimplemented by a device having a second hardware architecture beingdifferent from the first hardware architecture. The training method isthus robust. For example, the training method is robust againstdifferent ways of rounding float values.

After the first training image has been used for training the firstneural network, the above method (according to any embodiment) may beiterated (L1 in FIG. 5) for a plurality of training images.

According to some embodiments, the first neural network 104 may beassociated with a version number, the version number reflecting aversion number of the reference neural network 302 at the time when thefirst neural network was trained. This embodiment may be used to makesure that when feature vectors are compared between neural networks, thesame version of the reference neural network (i.e., reference neuralnetwork 302) has been used for training. Otherwise, comparisons of thefeature vectors cannot be done.

FIG. 4 shows by way of example a system 400 comprising a plurality ofdevices 404-408, wherein each device 404-408 comprises a neural networktrained according to this disclosure. The system 400 can thus be usedfor tracking an object between the devices, since the output featurevectors from the neural networks can be compared. For example, eachdevice can be adapted to extract an object from an image, using thefirst neural network to process image data of the extracted object andtransmit a feature vector 106 outputted from the first neural network.According to some embodiments, at least one of the plurality of devicesis a network camera, wherein the object is extracted from an imagecaptured by the network camera.

In the system 400, an object tracking unit 402 adapted to receivefeature vectors from the devices may be used for tracking an objectthrough the system of devices based on the received feature vectors 106.The object tracking unit 402 may be implemented in at least one of theplurality of devices, which means that the object tracking unit itselfis a device similar to the plurality of devices 404-408 and alsocomprises a neural network trained as described herein. The system 400may thus be a peer-to-peer network or any other suitable networkarchitecture. In this case, the transmission of a feature vector 106from a device of the plurality of devices 404-408 may be implementedusing unicast, multicast or broadcast transmission. In otherembodiments, the object tracking unit 402 is implemented in a furtherdevice separate from the plurality of devices 404-408 and connected toeach of the plurality of devices 404-408. In this embodiment, the objecttracking unit 402 may be implemented in a server or similar tofacilitate a central handling of tracking of object. The transmission offeature vectors between the plurality of devices 404-408 and theseparate object tracking unit 402 may thus be dedicated transmissions(i.e., to a dedicated receiver of the feature vector 106).

According to some embodiments, the first neural network of each of theplurality of devices further is associated a version number 410. Asdescribed above, the version number reflects a version number of thereference neural network at the time when the first neural network wastrained. In this case, the version number 410 of a device of theplurality of devices 404-408 is transmitted together with the featurevector 106 outputted from the first neural network. The object trackingunit may thus be adapted to track an object through the system ofdevices based on the received feature vectors and version numbers, andmake sure that only feature vectors received from devices having aneural network with the same version number is compared.

In case the version number 410 differs for a received feature vector106, the object tracking unit 402 may disregard the feature vector.According to other embodiments, the object tracking unit may requestanother device 404-406, having the correct version number associated toits neural network, or for example, a server having implemented a neuralnetwork of associated with the correct version number, to re-process theimage data being the cause of the feature vector with the wrong versionnumber, and to transmit a new feature vector to the object tracking unit402. The object tracking unit 402 may also trigger an update(re-training) of the neural network with the wrong (old) version number,and/or flag the device accordingly.

What is claimed is:
 1. A method for training a first neural networkbeing adapted to process image data and output a vector of valuesforming a feature vector for the processed image data, the methodcomprising: retrieving a reference feature vector, the reference featurevector being calculated by processing a first training image by areference neural network, the reference neural network being adapted toprocess image data and output a vector of values forming a featurevector for the processed image data; and training the first neuralnetwork to optimize a cost function, the cost function comprising atleast a first distance measure between the reference feature vector anda feature vector outputted by the first neural network when processingthe first training image, wherein the cost function is adapted tominimize the first distance measure, wherein the first neural networkand the reference neural network are different types of neural networks.2. The method of claim 1, wherein the first neural network has aninternal number representation comprising a first bit width, and a firstnetwork architecture, wherein the reference neural network has aninternal number representation comprising a second bit width, and asecond network architecture, wherein the first bit width differs fromthe second bit width and/or the first network architecture differs fromthe second network architecture.
 3. The method of claim 1, wherein thereference neural network has been trained using a triplet-based costfunction, wherein the triplet-based cost function separates a pair ofinput images of a same classification or identification from a thirdinput image of another classification or identification, such that adifference between a first distance between the pair of input images ofthe same classification or identification, and a second distance betweenone of the pair of input images of the same classification oridentification and the third input image, is at least a distance margin,alpha, wherein the step of training the first neural network to optimizethe cost function comprises reducing the first distance measure to atleast alpha divided by four.
 4. The method of claim 1, wherein theretrieving a reference feature vector comprises transmitting the firsttraining image to the reference neural network, processing the firsttraining image by the reference neural network, and retrieving theoutputted feature vector from the reference neural network.
 5. Themethod of claim 1, wherein the retrieving a reference feature vectorcomprises using data pertaining to the first training image as anidentifier in a database comprising feature vectors and identifiers foreach reference vector, and retrieving the feature vector correspondingto the identifier from the database.
 6. The method of claim 1, whereinthe retrieving the reference feature vector and training the firstneural network to optimize the cost function is iterative for aplurality of training images.
 7. The method of claim 1, furthercomprising: associating the first neural network with a version number,the version number reflecting a version number of the reference neuralnetwork at the time when the first neural network was trained withreference feature vectors from the reference neural network.
 8. Anarticle of manufacture including a non-transitory computer-readablestorage medium having instructions stored thereon, execution of which bya computing device causes the computing device to perform operations fortraining a first neural network comprising: retrieving a referencefeature vector, the reference feature vector being calculated byprocessing a first training image by a reference neural network, thereference neural network being adapted to process image data and outputa vector of values forming a feature vector for the processed imagedata; and training the first neural network to optimize a cost function,the cost function comprising at least a first distance measure betweenthe reference feature vector and a feature vector outputted by the firstneural network when processing the first training image, wherein thecost function is adapted to minimize the first distance measure, whereinthe first neural network and the reference neural network are differenttypes of neural networks.
 9. A device comprising: a first neural networkbeing configured to process image data and output a vector of valuesforming a feature vector for the processed image data; and a processorconfigured to: retrieve a reference feature vector, the referencefeature vector being calculated by processing a first training image bya reference neural network, the reference neural network being adaptedto process image data and output a vector of values forming a featurevector for the processed image data; and train the first neural networkto optimize a cost function, the cost function comprising at least afirst distance measure between the reference feature vector and thefeature vector outputted by the first neural network when processing thefirst training image, wherein the cost function is adapted to minimizethe first distance measure, wherein the first neural network and thereference neural network are different types of neural networks.
 10. Thedevice of claim 9, wherein the first neural network has an internalnumber representation comprising a first bit width, and a first networkarchitecture, and wherein the reference neural network has an internalnumber representation comprising a second bit width, and a secondnetwork architecture, wherein the first bit width differs from thesecond bit width and/or the first network architecture differs from thesecond network architecture.
 11. The device of claim 9, wherein thedevice has a first hardware architecture, and wherein the referenceneural network is implemented by a device having a second hardwarearchitecture being different from the first hardware architecture.
 12. Asystem comprising: a plurality of devices, each device comprising: afirst neural network being adapted to process image data and output avector of values forming a feature vector for the processed image data;and a processor configured to retrieve a reference feature vector, thereference feature vector being calculated by processing a first trainingimage by a reference neural network, the reference neural network beingadapted to process image data and output a vector of values forming afeature vector for the processed image data, and train the first neuralnetwork to optimize a cost function, the cost function comprising atleast a first distance measure between the reference feature vector andthe feature vector outputted by the first neural network when processingthe first training image, wherein the cost function is adapted tominimize the first distance measure, wherein the first neural networkand the reference neural network are different types of neural networks;wherein each device is further configured to extract an object from animage, using the first neural network to process image data of theextracted object and transmit a feature vector outputted from the firstneural network; and an object tracking unit configured to receivefeature vectors from the plurality of devices, and track an objectthrough the plurality of devices at least partly based on the receivedfeature vectors.
 13. The system according to claim 12, wherein the firstneural network of each of the plurality of devices further is associateda version number, the version number reflecting a version number of thereference neural network at the time when the first neural network wastrained, wherein the version number being associated to the first neuralnetwork of a device of the plurality of devices is transmitted togetherwith the feature vector outputted from the first neural network, andwherein the object tracking unit is adapted to track an object throughthe system of devices based on the received feature vectors and versionnumbers.